﻿#pragma warning disable 1998

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using NuMvvm.Commands;

namespace NuMvvm.Tests
{
    [TestFixture]
    public class AsyncRelayCommandTest
    {
        [TestCase]
        public async Task AsyncRelayCommand()
        {
            bool called = false;

            var relayCommand = new AsyncDelegateCommand(async (cancellationToken) => { called = true; });
            await relayCommand.ExecuteAsync();

            Assert.IsTrue(called);
        }

        [TestCase]
        public async Task AsyncRelayCommandGeneric()
        {
            string result = null;

            var relayCommand = new AsyncDelegateCommand<string>(async (arg, cancellationToken) =>
            {
                result = arg;
            });
            await relayCommand.ExecuteAsync("Hello World!");

            Assert.AreEqual(result, "Hello World!");
        }
    }
}
